home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / gcc.info-11 (.txt) < prev    next >
GNU Info File  |  1995-06-16  |  43KB  |  736 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  5. Boston, MA 02111-1307 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  7. Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided also
  13. that the sections entitled "GNU General Public License," "Funding for
  14. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the sections entitled "GNU General Public
  21. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  22. `Look And Feel'", and this permission notice, may be included in
  23. translations approved by the Free Software Foundation instead of in the
  24. original English.
  25. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  26. Cross-Compiler Problems
  27. =======================
  28.    You may run into problems with cross compilation on certain machines,
  29. for several reasons.
  30.    * Cross compilation can run into trouble for certain machines because
  31.      some target machines' assemblers require floating point numbers to
  32.      be written as *integer* constants in certain contexts.
  33.      The compiler writes these integer constants by examining the
  34.      floating point value as an integer and printing that integer,
  35.      because this is simple to write and independent of the details of
  36.      the floating point representation.  But this does not work if the
  37.      compiler is running on a different machine with an incompatible
  38.      floating point format, or even a different byte-ordering.
  39.      In addition, correct constant folding of floating point values
  40.      requires representing them in the target machine's format.  (The C
  41.      standard does not quite require this, but in practice it is the
  42.      only way to win.)
  43.      It is now possible to overcome these problems by defining macros
  44.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  45.      work for each target machine.  *Note Cross-compilation::.
  46.    * At present, the program `mips-tfile' which adds debug support to
  47.      object files on MIPS systems does not work in a cross compile
  48.      environment.
  49. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  50. Interoperation
  51. ==============
  52.    This section lists various difficulties encountered in using GNU C or
  53. GNU C++ together with other compilers or with the assemblers, linkers,
  54. libraries and debuggers on certain systems.
  55.    * Objective C does not work on the RS/6000.
  56.    * GNU C++ does not do name mangling in the same way as other C++
  57.      compilers.  This means that object files compiled with one compiler
  58.      cannot be used with another.
  59.      This effect is intentional, to protect you from more subtle
  60.      problems.  Compilers differ as to many internal details of C++
  61.      implementation, including: how class instances are laid out, how
  62.      multiple inheritance is implemented, and how virtual function
  63.      calls are handled.  If the name encoding were made the same, your
  64.      programs would link against libraries provided from other
  65.      compilers--but the programs would then crash when run.
  66.      Incompatible libraries are then detected at link time, rather than
  67.      at run time.
  68.    * Older GDB versions sometimes fail to read the output of GNU CC
  69.      version 2.  If you have trouble, get GDB version 4.4 or later.
  70.    * DBX rejects some files produced by GNU CC, though it accepts
  71.      similar constructs in output from PCC.  Until someone can supply a
  72.      coherent description of what is valid DBX input and what is not,
  73.      there is nothing I can do about these problems.  You are on your
  74.      own.
  75.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  76.      code, you must use some other assembler, such as `/bin/as'.
  77.    * On some BSD systems, including some versions of Ultrix, use of
  78.      profiling causes static variable destructors (currently used only
  79.      in C++) not to be run.
  80.    * Use of `-I/usr/include' may cause trouble.
  81.      Many systems come with header files that won't work with GNU CC
  82.      unless corrected by `fixincludes'.  The corrected header files go
  83.      in a new directory; GNU CC searches this directory before
  84.      `/usr/include'.  If you use `-I/usr/include', this tells GNU CC to
  85.      search `/usr/include' earlier on, before the corrected headers.
  86.      The result is that you get the uncorrected header files.
  87.      Instead, you should use these options (when compiling C programs):
  88.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  89.      For C++ programs, GNU CC also uses a special directory that
  90.      defines C++ interfaces to standard C subroutines.  This directory
  91.      is meant to be searched *before* other standard include
  92.      directories, so that it takes precedence.  If you are compiling
  93.      C++ programs and specifying include directories explicitly, use
  94.      this option first, then the two options above:
  95.           -I/usr/local/lib/g++-include
  96.    * On some SGI systems, when you use `-lgl_s' as an option, it gets
  97.      translated magically to `-lgl_s -lX11_s -lc_s'.  Naturally, this
  98.      does not happen when you use GNU CC.  You must specify all three
  99.      options explicitly.
  100.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  101.      boundary, and it expects every `double' to be so aligned.  The Sun
  102.      compiler usually gives `double' values 8-byte alignment, with one
  103.      exception: function arguments of type `double' may not be aligned.
  104.      As a result, if a function compiled with Sun CC takes the address
  105.      of an argument of type `double' and passes this pointer of type
  106.      `double *' to a function compiled with GNU CC, dereferencing the
  107.      pointer may cause a fatal signal.
  108.      One way to solve this problem is to compile your entire program
  109.      with GNU CC.  Another solution is to modify the function that is
  110.      compiled with Sun CC to copy the argument into a local variable;
  111.      local variables are always properly aligned.  A third solution is
  112.      to modify the function that uses the pointer to dereference it via
  113.      the following function `access_double' instead of directly with
  114.      `*':
  115.           inline double
  116.           access_double (double *unaligned_ptr)
  117.           {
  118.             union d2i { double d; int i[2]; };
  119.           
  120.             union d2i *p = (union d2i *) unaligned_ptr;
  121.             union d2i u;
  122.           
  123.             u.i[0] = p->i[0];
  124.             u.i[1] = p->i[1];
  125.           
  126.             return u.d;
  127.           }
  128.      Storing into the pointer can be done likewise with the same union.
  129.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  130.      allocate memory that is only 4 byte aligned.  Since GNU CC on the
  131.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  132.      fatal signal if doubles are stored in memory allocated by the
  133.      `libmalloc.a' library.
  134.      The solution is to not use the `libmalloc.a' library.  Use instead
  135.      `malloc' and related functions from `libc.a'; they do not have
  136.      this problem.
  137.    * Sun forgot to include a static version of `libdl.a' with some
  138.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  139.      when linking static binaries (that is, if you use `-static').  If
  140.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  141.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  142.      from the MIT version of X windows.
  143.    * The 128-bit long double format that the Sparc port supports
  144.      currently works by using the architecturally defined quad-word
  145.      floating point instructions.  Since there is no hardware that
  146.      supports these instructions they must be emulated by the operating
  147.      system.  Long doubles do not work in Sun OS versions 4.0.3 and
  148.      earlier, because the kernel eumulator uses an obsolete and
  149.      incompatible format.  Long doubles do not work in Sun OS version
  150.      4.1.1 due to a problem in a Sun library.  Long doubles do work on
  151.      Sun OS versions 4.1.2 and higher, but GNU CC does not enable them
  152.      by default.  Long doubles appear to work in Sun OS 5.x (Solaris
  153.      2.x).
  154.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  155.      compile GNU CC correctly.  We do not yet know why.  However, GNU CC
  156.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  157.      and can compile itself properly on 9.01.
  158.    * On the HP PA machine, ADB sometimes fails to work on functions
  159.      compiled with GNU CC.  Specifically, it fails to work on functions
  160.      that use `alloca' or variable-size arrays.  This is because GNU CC
  161.      doesn't generate HP-UX unwind descriptors for such functions.  It
  162.      may even be impossible to generate them.
  163.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  164.      use the preliminary GNU tools (*note Installation::.).
  165.    * Taking the address of a label may generate errors from the HP-UX
  166.      PA assembler.  GAS for the PA does not have this problem.
  167.    * Using floating point parameters for indirect calls to static
  168.      functions will not work when using the HP assembler.  There simply
  169.      is no way for GCC to specify what registers hold arguments for
  170.      static functions when using the HP assembler.  GAS for the PA does
  171.      not have this problem.
  172.    * In extremely rare cases involvving some very large functions you
  173.      may receive errors from the HP linker complaining about an out of
  174.      bounds unconditional branch offset.  This used to occur more often
  175.      in previous versions of GNU CC, but is now exceptionally rare.  If
  176.      you should run into it, you can work around by making your
  177.      function smaller.
  178.    * GNU CC compiled code sometimes emits warnings from the HP-UX
  179.      assembler of the form:
  180.           (warning) Use of GR3 when
  181.             frame >= 8192 may cause conflict.
  182.      These warnings are harmless and can be safely ignored.
  183.    * The current version of the assembler (`/bin/as') for the RS/6000
  184.      has certain problems that prevent the `-g' option in GCC from
  185.      working.  Note that `Makefile.in' uses `-g' by default when
  186.      compiling `libgcc2.c'.
  187.      IBM has produced a fixed version of the assembler.  The upgraded
  188.      assembler unfortunately was not included in any of the AIX 3.2
  189.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  190.      should request PTF U403044 from IBM and users of AIX 3.2 should
  191.      request PTF U416277.  See the file `README.RS6000' for more
  192.      details on these updates.
  193.      You can test for the presense of a fixed assembler by using the
  194.      command
  195.           as -u < /dev/null
  196.      If the command exits normally, the assembler fix already is
  197.      installed.  If the assembler complains that "-u" is an unknown
  198.      flag, you need to order the fix.
  199.    * On the IBM RS/6000, compiling code of the form
  200.           extern int foo;
  201.           
  202.           ... foo ...
  203.           
  204.           static int foo;
  205.      will cause the linker to report an undefined symbol `foo'.
  206.      Although this behavior differs from most other systems, it is not a
  207.      bug because redefining an `extern' variable as `static' is
  208.      undefined in ANSI C.
  209.    * AIX on the RS/6000 provides support (NLS) for environments outside
  210.      of the United States.  Compilers and assemblers use NLS to support
  211.      locale-specific representations of various objects including
  212.      floating-point numbers ("." vs "," for separating decimal
  213.      fractions).  There have been problems reported where the library
  214.      linked with GCC does not produce the same floating-point formats
  215.      that the assembler accepts.  If you have this problem, set the
  216.      LANG environment variable to "C" or "En_US".
  217.    * Even if you specify `-fdollars-in-identifiers', you cannot
  218.      successfully use `$' in identifiers on the RS/6000 due to a
  219.      restriction in the IBM assembler.  GAS supports these identifiers.
  220.    * On the RS/6000, XLC version 1.3.0.0 will miscompile `jump.c'.  XLC
  221.      version 1.3.0.1 or later fixes this problem.  You can obtain
  222.      XLC-1.3.0.2 by requesting PTF 421749 from IBM.
  223.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  224.      that occurs when the `fldcr' instruction is used.  GNU CC uses
  225.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  226.      the option `-mno-serialize-volatile' if your version of the
  227.      assembler has this bug.
  228.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  229.      messages from the linker.  These warning messages complain of
  230.      mismatched psect attributes.  You can ignore them.  *Note VMS
  231.      Install::.
  232.    * On NewsOS version 3, if you include both of the files `stddef.h'
  233.      and `sys/types.h', you get an error because there are two typedefs
  234.      of `size_t'.  You should change `sys/types.h' by adding these
  235.      lines around the definition of `size_t':
  236.           #ifndef _SIZE_T
  237.           #define _SIZE_T
  238.           ACTUAL TYPEDEF HERE
  239.           #endif
  240.    * On the Alliant, the system's own convention for returning
  241.      structures and unions is unusual, and is not compatible with GNU
  242.      CC no matter what options are used.
  243.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
  244.      convention for structure and union returning.  Use the option
  245.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  246.      with it.
  247.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  248.      be saved by function calls.  However, the C compiler uses
  249.      conventions compatible with BSD Unix: registers 2 through 5 may be
  250.      clobbered by function calls.
  251.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  252.      use these options to produce code compatible with the Fortran
  253.      compiler:
  254.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  255.    * On the WE32k, you may find that programs compiled with GNU CC do
  256.      not work with the standard shared C library.  You may need to link
  257.      with the ordinary C compiler.  If you do so, you must specify the
  258.      following options:
  259.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.7.0 -lgcc -lc_s
  260.      The first specifies where to find the library `libgcc.a' specified
  261.      with the `-lgcc' option.
  262.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  263.      is no reason why it *should* matter which compilation program you
  264.      use to invoke `ld'.  If someone tracks this problem down, it can
  265.      probably be fixed easily.
  266.    * On the Alpha, you may get assembler errors about invalid syntax as
  267.      a result of floating point constants.  This is due to a bug in the
  268.      C library functions `ecvt', `fcvt' and `gcvt'.  Given valid
  269.      floating point numbers, they sometimes print `NaN'.
  270.    * On Irix 4.0.5F (and perhaps in some other versions), an assembler
  271.      bug sometimes reorders instructions incorrectly when optimization
  272.      is turned on.  If you think this may be happening to you, try
  273.      using the GNU assembler; GAS version 2.1 supports ECOFF on Irix.
  274.      Or use the `-noasmopt' option when you compile GNU CC with itself,
  275.      and then again when you compile your program.  (This is a temporary
  276.      kludge to turn off assembler optimization on Irix.)  If this
  277.      proves to be what you need, edit the assembler spec in the file
  278.      `specs' so that it unconditionally passes `-O0' to the assembler,
  279.      and never passes `-O2' or `-O3'.
  280. File: gcc.info,  Node: External Bugs,  Next: Incompatibilities,  Prev: Interoperation,  Up: Trouble
  281. Problems Compiling Certain Programs
  282. ===================================
  283.    Certain programs have problems compiling.
  284.    * Parse errors may occur compiling X11 on a Decstation running
  285.      Ultrix 4.2 because of problems in DEC's versions of the X11 header
  286.      files `X11/Xlib.h' and `X11/Xutil.h'.  People recommend adding
  287.      `-I/usr/include/mit' to use the MIT versions of the header files,
  288.      using the `-traditional' switch to turn off ANSI C, or fixing the
  289.      header files by adding this:
  290.           #ifdef __STDC__
  291.           #define NeedFunctionPrototypes 0
  292.           #endif
  293.    * If you have trouble compiling Perl on a SunOS 4 system, it may be
  294.      because Perl specifies `-I/usr/ucbinclude'.  This accesses the
  295.      unfixed header files.  Perl specifies the options
  296.           -traditional -Dvolatile=__volatile__
  297.           -I/usr/include/sun -I/usr/ucbinclude
  298.           -fpcc-struct-return
  299.      most of which are unnecessary with GCC 2.4.5 and newer versions.
  300.      You can make a properly working Perl by setting `ccflags' to
  301.      `-fwritable-strings' (implied by the `-traditional' in the
  302.      original options) and `cppflags' to empty in `config.sh', then
  303.      typing `./doSH; make depend; make'.
  304.    * On various 386 Unix systems derived from System V, including SCO,
  305.      ISC, and ESIX, you may get error messages about running out of
  306.      virtual memory while compiling certain programs.
  307.      You can prevent this problem by linking GNU CC with the GNU malloc
  308.      (which thus replaces the malloc that comes with the system).  GNU
  309.      malloc is available as a separate package, and also in the file
  310.      `src/gmalloc.c' in the GNU Emacs 19 distribution.
  311.      If you have installed GNU malloc as a separate library package,
  312.      use this option when you relink GNU CC:
  313.           MALLOC=/usr/local/lib/libgmalloc.a
  314.      Alternatively, if you have compiled `gmalloc.c' from Emacs 19, copy
  315.      the object file to `gmalloc.o' and use this option when you relink
  316.      GNU CC:
  317.           MALLOC=gmalloc.o
  318. File: gcc.info,  Node: Incompatibilities,  Next: Fixed Headers,  Prev: External Bugs,  Up: Trouble
  319. Incompatibilities of GNU CC
  320. ===========================
  321.    There are several noteworthy incompatibilities between GNU C and most
  322. existing (non-ANSI) versions of C.  The `-traditional' option
  323. eliminates many of these incompatibilities, *but not all*, by telling
  324. GNU C to behave like the other C compilers.
  325.    * GNU CC normally makes string constants read-only.  If several
  326.      identical-looking string constants are used, GNU CC stores only one
  327.      copy of the string.
  328.      One consequence is that you cannot call `mktemp' with a string
  329.      constant argument.  The function `mktemp' always alters the string
  330.      its argument points to.
  331.      Another consequence is that `sscanf' does not work on some systems
  332.      when passed a string constant as its format control string or
  333.      input.  This is because `sscanf' incorrectly tries to write into
  334.      the string constant.  Likewise `fscanf' and `scanf'.
  335.      The best solution to these problems is to change the program to use
  336.      `char'-array variables with initialization strings for these
  337.      purposes instead of string constants.  But if this is not possible,
  338.      you can use the `-fwritable-strings' flag, which directs GNU CC to
  339.      handle string constants the same way most C compilers do.
  340.      `-traditional' also has this effect, among others.
  341.    * `-2147483648' is positive.
  342.      This is because 2147483648 cannot fit in the type `int', so
  343.      (following the ANSI C rules) its data type is `unsigned long int'.
  344.      Negating this value yields 2147483648 again.
  345.    * GNU CC does not substitute macro arguments when they appear inside
  346.      of string constants.  For example, the following macro in GNU CC
  347.           #define foo(a) "a"
  348.      will produce output `"a"' regardless of what the argument A is.
  349.      The `-traditional' option directs GNU CC to handle such cases
  350.      (among others) in the old-fashioned (non-ANSI) fashion.
  351.    * When you use `setjmp' and `longjmp', the only automatic variables
  352.      guaranteed to remain valid are those declared `volatile'.  This is
  353.      a consequence of automatic register allocation.  Consider this
  354.      function:
  355.           jmp_buf j;
  356.           
  357.           foo ()
  358.           {
  359.             int a, b;
  360.           
  361.             a = fun1 ();
  362.             if (setjmp (j))
  363.               return a;
  364.           
  365.             a = fun2 ();
  366.             /* `longjmp (j)' may occur in `fun3'. */
  367.             return a + fun3 ();
  368.           }
  369.      Here `a' may or may not be restored to its first value when the
  370.      `longjmp' occurs.  If `a' is allocated in a register, then its
  371.      first value is restored; otherwise, it keeps the last value stored
  372.      in it.
  373.      If you use the `-W' option with the `-O' option, you will get a
  374.      warning when GNU CC thinks such a problem might be possible.
  375.      The `-traditional' option directs GNU C to put variables in the
  376.      stack by default, rather than in registers, in functions that call
  377.      `setjmp'.  This results in the behavior found in traditional C
  378.      compilers.
  379.    * Programs that use preprocessing directives in the middle of macro
  380.      arguments do not work with GNU CC.  For example, a program like
  381.      this will not work:
  382.           foobar (
  383.           #define luser
  384.                   hack)
  385.      ANSI C does not permit such a construct.  It would make sense to
  386.      support it when `-traditional' is used, but it is too much work to
  387.      implement.
  388.    * Declarations of external variables and functions within a block
  389.      apply only to the block containing the declaration.  In other
  390.      words, they have the same scope as any other declaration in the
  391.      same place.
  392.      In some other C compilers, a `extern' declaration affects all the
  393.      rest of the file even if it happens within a block.
  394.      The `-traditional' option directs GNU C to treat all `extern'
  395.      declarations as global, like traditional compilers.
  396.    * In traditional C, you can combine `long', etc., with a typedef
  397.      name, as shown here:
  398.           typedef int foo;
  399.           typedef long foo bar;
  400.      In ANSI C, this is not allowed: `long' and other type modifiers
  401.      require an explicit `int'.  Because this criterion is expressed by
  402.      Bison grammar rules rather than C code, the `-traditional' flag
  403.      cannot alter it.
  404.    * PCC allows typedef names to be used as function parameters.  The
  405.      difficulty described immediately above applies here too.
  406.    * PCC allows whitespace in the middle of compound assignment
  407.      operators such as `+='.  GNU CC, following the ANSI standard, does
  408.      not allow this.  The difficulty described immediately above
  409.      applies here too.
  410.    * GNU CC complains about unterminated character constants inside of
  411.      preprocessing conditionals that fail.  Some programs have English
  412.      comments enclosed in conditionals that are guaranteed to fail; if
  413.      these comments contain apostrophes, GNU CC will probably report an
  414.      error.  For example, this code would produce an error:
  415.           #if 0
  416.           You can't expect this to work.
  417.           #endif
  418.      The best solution to such a problem is to put the text into an
  419.      actual C comment delimited by `/*...*/'.  However, `-traditional'
  420.      suppresses these error messages.
  421.    * Many user programs contain the declaration `long time ();'.  In the
  422.      past, the system header files on many systems did not actually
  423.      declare `time', so it did not matter what type your program
  424.      declared it to return.  But in systems with ANSI C headers, `time'
  425.      is declared to return `time_t', and if that is not the same as
  426.      `long', then `long time ();' is erroneous.
  427.      The solution is to change your program to use `time_t' as the
  428.      return type of `time'.
  429.    * When compiling functions that return `float', PCC converts it to a
  430.      double.  GNU CC actually returns a `float'.  If you are concerned
  431.      with PCC compatibility, you should declare your functions to return
  432.      `double'; you might as well say what you mean.
  433.    * When compiling functions that return structures or unions, GNU CC
  434.      output code normally uses a method different from that used on most
  435.      versions of Unix.  As a result, code compiled with GNU CC cannot
  436.      call a structure-returning function compiled with PCC, and vice
  437.      versa.
  438.      The method used by GNU CC is as follows: a structure or union
  439.      which is 1, 2, 4 or 8 bytes long is returned like a scalar.  A
  440.      structure or union with any other size is stored into an address
  441.      supplied by the caller (usually in a special, fixed register, but
  442.      on some machines it is passed on the stack).  The
  443.      machine-description macros `STRUCT_VALUE' and
  444.      `STRUCT_INCOMING_VALUE' tell GNU CC where to pass this address.
  445.      By contrast, PCC on most target machines returns structures and
  446.      unions of any size by copying the data into an area of static
  447.      storage, and then returning the address of that storage as if it
  448.      were a pointer value.  The caller must copy the data from that
  449.      memory area to the place where the value is wanted.  GNU CC does
  450.      not use this method because it is slower and nonreentrant.
  451.      On some newer machines, PCC uses a reentrant convention for all
  452.      structure and union returning.  GNU CC on most of these machines
  453.      uses a compatible convention when returning structures and unions
  454.      in memory, but still returns small structures and unions in
  455.      registers.
  456.      You can tell GNU CC to use a compatible convention for all
  457.      structure and union returning with the option
  458.      `-fpcc-struct-return'.
  459.    * GNU C complains about program fragments such as `0x74ae-0x4000'
  460.      which appear to be two hexadecimal constants separated by the minus
  461.      operator.  Actually, this string is a single "preprocessing token".
  462.      Each such token must correspond to one token in C.  Since this
  463.      does not, GNU C prints an error message.  Although it may appear
  464.      obvious that what is meant is an operator and two values, the ANSI
  465.      C standard specifically requires that this be treated as erroneous.
  466.      A "preprocessing token" is a "preprocessing number" if it begins
  467.      with a digit and is followed by letters, underscores, digits,
  468.      periods and `e+', `e-', `E+', or `E-' character sequences.
  469.      To make the above program fragment valid, place whitespace in
  470.      front of the minus sign.  This whitespace will end the
  471.      preprocessing number.
  472. File: gcc.info,  Node: Fixed Headers,  Next: Standard Libraries,  Prev: Incompatibilities,  Up: Trouble
  473. Fixed Header Files
  474. ==================
  475.    GNU CC needs to install corrected versions of some system header
  476. files.  This is because most target systems have some header files that
  477. won't work with GNU CC unless they are changed.  Some have bugs, some
  478. are incompatible with ANSI C, and some depend on special features of
  479. other compilers.
  480.    Installing GNU CC automatically creates and installs the fixed header
  481. files, by running a program called `fixincludes' (or for certain
  482. targets an alternative such as `fixinc.svr4').  Normally, you don't
  483. need to pay attention to this.  But there are cases where it doesn't do
  484. the right thing automatically.
  485.    * If you update the system's header files, such as by installing a
  486.      new system version, the fixed header files of GNU CC are not
  487.      automatically updated.  The easiest way to update them is to
  488.      reinstall GNU CC.  (If you want to be clever, look in the makefile
  489.      and you can find a shortcut.)
  490.    * On some systems, in particular SunOS 4, header file directories
  491.      contain machine-specific symbolic links in certain places.  This
  492.      makes it possible to share most of the header files among hosts
  493.      running the same version of SunOS 4 on different machine models.
  494.      The programs that fix the header files do not understand this
  495.      special way of using symbolic links; therefore, the directory of
  496.      fixed header files is good only for the machine model used to
  497.      build it.
  498.      In SunOS 4, only programs that look inside the kernel will notice
  499.      the difference between machine models.  Therefore, for most
  500.      purposes, you need not be concerned about this.
  501.      It is possible to make separate sets of fixed header files for the
  502.      different machine models, and arrange a structure of symbolic
  503.      links so as to use the proper set, but you'll have to do this by
  504.      hand.
  505.    * On Lynxos, GNU CC by default does not fix the header files.  This
  506.      is because bugs in the shell cause the `fixincludes' script to
  507.      fail.
  508.      This means you will encounter problems due to bugs in the system
  509.      header files.  It may be no comfort that they aren't GNU CC's
  510.      fault, but it does mean that there's nothing for us to do about
  511.      them.
  512. File: gcc.info,  Node: Standard Libraries,  Next: Disappointments,  Prev: Fixed Headers,  Up: Trouble
  513. Standard Libraries
  514. ==================
  515.    GNU CC by itself attempts to be what the ISO/ANSI C standard calls a
  516. "conforming freestanding implementation".  This means all ANSI C
  517. language features are available, as well as the contents of `float.h',
  518. `limits.h', `stdarg.h', and `stddef.h'.  The rest of the C library is
  519. supplied by the vendor of the operating system.  If that C library
  520. doesn't conform to the C standards, then your programs might get
  521. warnings (especially when using `-Wall') that you don't expect.
  522.    For example, the `sprintf' function on SunOS 4.1.3 returns `char *'
  523. while the C standard says that `sprintf' returns an `int'.  The
  524. `fixincludes' program could make the prototype for this function match
  525. the Standard, but that would be wrong, since the function will still
  526. return `char *'.
  527.    If you need a Standard compliant library, then you need to find one,
  528. as GNU CC does not provide one.  The GNU C library (called `glibc') has
  529. been ported to a number of operating systems, and provides ANSI/ISO,
  530. POSIX, BSD and SystemV compatibility.  You could also ask your operating
  531. system vendor if newer libraries are available.
  532. File: gcc.info,  Node: Disappointments,  Next: C++ Misunderstandings,  Prev: Standard Libraries,  Up: Trouble
  533. Disappointments and Misunderstandings
  534. =====================================
  535.    These problems are perhaps regrettable, but we don't know any
  536. practical way around them.
  537.    * Certain local variables aren't recognized by debuggers when you
  538.      compile with optimization.
  539.      This occurs because sometimes GNU CC optimizes the variable out of
  540.      existence.  There is no way to tell the debugger how to compute the
  541.      value such a variable "would have had", and it is not clear that
  542.      would be desirable anyway.  So GNU CC simply does not mention the
  543.      eliminated variable when it writes debugging information.
  544.      You have to expect a certain amount of disagreement between the
  545.      executable and your source code, when you use optimization.
  546.    * Users often think it is a bug when GNU CC reports an error for code
  547.      like this:
  548.           int foo (struct mumble *);
  549.           
  550.           struct mumble { ... };
  551.           
  552.           int foo (struct mumble *x)
  553.           { ... }
  554.      This code really is erroneous, because the scope of `struct
  555.      mumble' in the prototype is limited to the argument list
  556.      containing it.  It does not refer to the `struct mumble' defined
  557.      with file scope immediately below--they are two unrelated types
  558.      with similar names in different scopes.
  559.      But in the definition of `foo', the file-scope type is used
  560.      because that is available to be inherited.  Thus, the definition
  561.      and the prototype do not match, and you get an error.
  562.      This behavior may seem silly, but it's what the ANSI standard
  563.      specifies.  It is easy enough for you to make your code work by
  564.      moving the definition of `struct mumble' above the prototype.
  565.      It's not worth being incompatible with ANSI C just to avoid an
  566.      error for the example shown above.
  567.    * Accesses to bitfields even in volatile objects works by accessing
  568.      larger objects, such as a byte or a word.  You cannot rely on what
  569.      size of object is accessed in order to read or write the bitfield;
  570.      it may even vary for a given bitfield according to the precise
  571.      usage.
  572.      If you care about controlling the amount of memory that is
  573.      accessed, use volatile but do not use bitfields.
  574.    * GNU CC comes with shell scripts to fix certain known problems in
  575.      system header files.  They install corrected copies of various
  576.      header files in a special directory where only GNU CC will
  577.      normally look for them.  The scripts adapt to various systems by
  578.      searching all the system header files for the problem cases that
  579.      we know about.
  580.      If new system header files are installed, nothing automatically
  581.      arranges to update the corrected header files.  You will have to
  582.      reinstall GNU CC to fix the new header files.  More specifically,
  583.      go to the build directory and delete the files `stmp-fixinc' and
  584.      `stmp-headers', and the subdirectory `include'; then do `make
  585.      install' again.
  586.    * On 68000 systems, you can get paradoxical results if you test the
  587.      precise values of floating point numbers.  For example, you can
  588.      find that a floating point value which is not a NaN is not equal
  589.      to itself.  This results from the fact that the the floating point
  590.      registers hold a few more bits of precision than fit in a `double'
  591.      in memory.  Compiled code moves values between memory and floating
  592.      point registers at its convenience, and moving them into memory
  593.      truncates them.
  594.      You can partially avoid this problem by using the `-ffloat-store'
  595.      option (*note Optimize Options::.).
  596.    * On the MIPS, variable argument functions using `varargs.h' cannot
  597.      have a floating point value for the first argument.  The reason
  598.      for this is that in the absence of a prototype in scope, if the
  599.      first argument is a floating point, it is passed in a floating
  600.      point register, rather than an integer register.
  601.      If the code is rewritten to use the ANSI standard `stdarg.h'
  602.      method of variable arguments, and the prototype is in scope at the
  603.      time of the call, everything will work fine.
  604. File: gcc.info,  Node: C++ Misunderstandings,  Next: Protoize Caveats,  Prev: Disappointments,  Up: Trouble
  605. Common Misunderstandings with GNU C++
  606. =====================================
  607.    C++ is a complex language and an evolving one, and its standard
  608. definition (the ANSI C++ draft standard) is also evolving.  As a result,
  609. your C++ compiler may occasionally surprise you, even when its behavior
  610. is correct.  This section discusses some areas that frequently give
  611. rise to questions of this sort.
  612. * Menu:
  613. * Static Definitions::  Static member declarations are not definitions
  614. * Temporaries::         Temporaries may vanish before you expect
  615. File: gcc.info,  Node: Static Definitions,  Next: Temporaries,  Up: C++ Misunderstandings
  616. Declare *and* Define Static Members
  617. -----------------------------------
  618.    When a class has static data members, it is not enough to *declare*
  619. the static member; you must also *define* it.  For example:
  620.      class Foo
  621.      {
  622.        ...
  623.        void method();
  624.        static int bar;
  625.      };
  626.    This declaration only establishes that the class `Foo' has an `int'
  627. named `Foo::bar', and a member function named `Foo::method'.  But you
  628. still need to define *both* `method' and `bar' elsewhere.  According to
  629. the draft ANSI standard, you must supply an initializer in one (and
  630. only one) source file, such as:
  631.      int Foo::bar = 0;
  632.    Other C++ compilers may not correctly implement the standard
  633. behavior.  As a result, when you switch to `g++' from one of these
  634. compilers, you may discover that a program that appeared to work
  635. correctly in fact does not conform to the standard: `g++' reports as
  636. undefined symbols any static data members that lack definitions.
  637. File: gcc.info,  Node: Temporaries,  Prev: Static Definitions,  Up: C++ Misunderstandings
  638. Temporaries May Vanish Before You Expect
  639. ----------------------------------------
  640.    It is dangerous to use pointers or references to *portions* of a
  641. temporary object.  The compiler may very well delete the object before
  642. you expect it to, leaving a pointer to garbage.  The most common place
  643. where this problem crops up is in classes like the libg++ `String'
  644. class, that define a conversion function to type `char *' or `const
  645. char *'.  However, any class that returns a pointer to some internal
  646. structure is potentially subject to this problem.
  647.    For example, a program may use a function `strfunc' that returns
  648. `String' objects, and another function `charfunc' that operates on
  649. pointers to `char':
  650.      String strfunc ();
  651.      void charfunc (const char *);
  652. In this situation, it may seem natural to write
  653. `charfunc (strfunc ());' based on the knowledge that class `String' has
  654. an explicit conversion to `char' pointers.  However, what really
  655. happens is akin to `charfunc (strfunc ().convert ());', where the
  656. `convert' method is a function to do the same data conversion normally
  657. performed by a cast.  Since the last use of the temporary `String'
  658. object is the call to the conversion function, the compiler may delete
  659. that object before actually calling `charfunc'.  The compiler has no
  660. way of knowing that deleting the `String' object will invalidate the
  661. pointer.  The pointer then points to garbage, so that by the time
  662. `charfunc' is called, it gets an invalid argument.
  663.    Code like this may run successfully under some other compilers,
  664. especially those that delete temporaries relatively late.  However, the
  665. GNU C++ behavior is also standard-conformant, so if your program depends
  666. on late destruction of temporaries it is not portable.
  667.    If you think this is surprising, you should be aware that the ANSI
  668. C++ committee continues to debate the lifetime-of-temporaries problem.
  669.    For now, at least, the safe way to write such code is to give the
  670. temporary a name, which forces it to remain until the end of the scope
  671. of the name.  For example:
  672.      String& tmp = strfunc ();
  673.      charfunc (tmp);
  674. File: gcc.info,  Node: Protoize Caveats,  Next: Non-bugs,  Prev: C++ Misunderstandings,  Up: Trouble
  675. Caveats of using `protoize'
  676. ===========================
  677.    The conversion programs `protoize' and `unprotoize' can sometimes
  678. change a source file in a way that won't work unless you rearrange it.
  679.    * `protoize' can insert references to a type name or type tag before
  680.      the definition, or in a file where they are not defined.
  681.      If this happens, compiler error messages should show you where the
  682.      new references are, so fixing the file by hand is straightforward.
  683.    * There are some C constructs which `protoize' cannot figure out.
  684.      For example, it can't determine argument types for declaring a
  685.      pointer-to-function variable; this you must do by hand.  `protoize'
  686.      inserts a comment containing `???' each time it finds such a
  687.      variable; so you can find all such variables by searching for this
  688.      string.  ANSI C does not require declaring the argument types of
  689.      pointer-to-function types.
  690.    * Using `unprotoize' can easily introduce bugs.  If the program
  691.      relied on prototypes to bring about conversion of arguments, these
  692.      conversions will not take place in the program without prototypes.
  693.      One case in which you can be sure `unprotoize' is safe is when you
  694.      are removing prototypes that were made with `protoize'; if the
  695.      program worked before without any prototypes, it will work again
  696.      without them.
  697.      You can find all the places where this problem might occur by
  698.      compiling the program with the `-Wconversion' option.  It prints a
  699.      warning whenever an argument is converted.
  700.    * Both conversion programs can be confused if there are macro calls
  701.      in and around the text to be converted.  In other words, the
  702.      standard syntax for a declaration or definition must not result
  703.      from expanding a macro.  This problem is inherent in the design of
  704.      C and cannot be fixed.  If only a few functions have confusing
  705.      macro calls, you can easily convert them manually.
  706.    * `protoize' cannot get the argument types for a function whose
  707.      definition was not actually compiled due to preprocessing
  708.      conditionals.  When this happens, `protoize' changes nothing in
  709.      regard to such a function.  `protoize' tries to detect such
  710.      instances and warn about them.
  711.      You can generally work around this problem by using `protoize' step
  712.      by step, each time specifying a different set of `-D' options for
  713.      compilation, until all of the functions have been converted.
  714.      There is no automatic way to verify that you have got them all,
  715.      however.
  716.    * Confusion may result if there is an occasion to convert a function
  717.      declaration or definition in a region of source code where there
  718.      is more than one formal parameter list present.  Thus, attempts to
  719.      convert code containing multiple (conditionally compiled) versions
  720.      of a single function header (in the same vicinity) may not produce
  721.      the desired (or expected) results.
  722.      If you plan on converting source files which contain such code, it
  723.      is recommended that you first make sure that each conditionally
  724.      compiled region of source code which contains an alternative
  725.      function header also contains at least one additional follower
  726.      token (past the final right parenthesis of the function header).
  727.      This should circumvent the problem.
  728.    * `unprotoize' can become confused when trying to convert a function
  729.      definition or declaration which contains a declaration for a
  730.      pointer-to-function formal argument which has the same name as the
  731.      function being defined or declared.  We recommand you avoid such
  732.      choices of formal parameter names.
  733.    * You might also want to correct some of the indentation by hand and
  734.      break long lines.  (The conversion programs don't write lines
  735.      longer than eighty characters in any case.)
  736.